<!-- 企业信息 -->
<template>
	<view>
		<image style="width: 750upx;height: 350upx;margin-bottom: 20upx;" :src="sourceImgSite + enterpriseData.cover" mode="aspectFill"  v-if="enterpriseData.cover"
		 @click="$api.previewImage([sourceImgSite + enterpriseData.cover])"></image>
		
		<HashCodeComponents :code="enterpriseData.hash" v-if="enterpriseData.hash" style="margin-bottom: 38upx;"></HashCodeComponents>
		
		<!-- 产品信息 -->
		<ListComponents title="产品信息" :dataList="msgListData" style="margin-bottom: 20upx;"></ListComponents>
		
		<!-- 企业资质 -->
		<view class="enterpriseQualification" >
			<view style="margin-bottom: 33upx;">企业资质</view>
			<view class="row-div image-view" style="margin-bottom: 7upx;" v-if="enterpriseData.firmCapitalResultFroms">
				<image :src="sourceImgSite + enterpriseData.firmCapitalResultFroms[0].capitalImg" mode="aspectFill" @click="$api.previewImage([sourceImgSite + enterpriseData.firmCapitalResultFroms[0].capitalImg])"></image>
			</view>
		</view>
		<!-- {{sourceImgSite + enterpriseData.firmCapitalResultFroms[0].capitalImg}} -->
		<view style="height: 51upx;"></view>
		
	</view>
</template>

<script>
	import ListComponents from './listComponents.vue';
	import HashCodeComponents from './hashCodeComponents.vue';
	import {mapState,mapMutations} from 'vuex';
	export default {
		props:{
			goodsCd: String,
			enterpriseInformation: Object,
		},
		components:{ListComponents,HashCodeComponents},
		computed: {...mapState(['hasLogin', 'downUrl', 'sourceImgSite', 'url'])},
		data() {
			return {
				enterpriseData:{
					cover: '',
					hash: ''
				},
				/* 信息列表 */
				msgListData:[],
			}
		},
		beforeMount() {
			this.infoRequest()
		},
		methods: {
			async infoRequest () {
				this.msgListData = [
					{field: 'name', title:'公司名称',value:''},
					{field: 'webUrl', title:'公司网址',value:''},
					{field: 'businessCode', title:'营业执照',value:''},
					{field: 'businessImg', title:'营业执照图片',value:'', image: ''},
					{field: 'person', title:'企业法人',value:''},
					{field: 'contacPerson', title:'联系人',value:''},
					{field: 'phone', title:'联系电话',value:''},
					{field: 'address', title:'公司地址',value:''},	
					{field: 'introduction', title:'企业简介',value:''},
				] 
				await this.getRequest();
			},
			getRequest () {
				this.$api.showLoading()
				this.$api.globalUtil.requestAjax({
					url: '/goodsSourceApi/producerSource',
					method: "POST",
					data: {id: this.enterpriseInformation.id},
					success: (res) => {
						if (res.data.success) {
							this.enterpriseData = res.data.response
							this.msgListDataMethod(this.enterpriseData)
						}
					},
					complate: () => (uni.stopPullDownRefresh(),this.$api.hideLoading())
				});
			},
			// 产品信息列表 数据便利 函数
			msgListDataMethod(obj){
				this.msgListData.forEach(item => {
					item.field == 'businessImg' ? item.image = this.sourceImgSite +  '/ipfs/' + obj[item.field] : item.value = obj[item.field]
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.hash-view{
		padding: 40upx 30upx;
		background: #FFFFFF;
		border-radius: 16upx;
		.hashcode-text {
			flex: 1;
			font-size: 26upx;
			word-break: break-all;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FE5E49;
			line-height: 42upx;
		}
		.copy-view {
			width: 90upx;
			height: 90upx;
			border: 1upx solid #EEEEEE;
			box-shadow: 0upx 3upx 8upx 0upx rgba(172, 170, 170, 0.1);
			border-radius: 45upx;
			font-size: 22upx;
			font-weight: 500;
			margin-left: 43upx;
			image {
				width: 30upx;
				height: 30upx;
				margin-bottom: 6upx;
			}
		}
	}
	.hash-title{
		font-size: 26upx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
		margin-bottom: 25upx;
	}

	/* 企业资质 */
	.enterpriseQualification{
		background: #FFFFFF;
		border-radius: 16upx;
		padding: 38upx 30upx;
		font-size: 30upx;
		font-family: PingFang SC;
		font-weight: bold;
		color: #333333;
		.image-view{
			image{
				width: 529upx;
				height: 357upx;
				border-radius: 10upx;
			}
		}
	}
</style>
